package com.jz.banner.screen.ui.activity

import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.jz.banner.screen.R
import com.jz.banner.screen.banner.utils.DeviceInfoUtils
import com.jz.banner.screen.guard.LocalService
import com.jz.banner.screen.ui.App
import com.jz.banner.screen.ui.activity.base.BaseActivity
import com.jz.banner.screen.utils.ARouterUtils
import com.jz.banner.screen.utils.CommUtils
import com.jz.banner.screen.utils.eventbus.Event
import com.jz.banner.screen.utils.eventbus.EventCode
import kotlinx.android.synthetic.main.activity_login.*

@Route(path = ARouterUtils.LoginActivity)
class LoginActivity : BaseActivity() {
    override fun getContentLayout(): Any = R.layout.activity_login

    override fun beforeSetContentView() {
        App.flag = 0
    }

    override fun initView() {
        startService(Intent(this, LocalService::class.java))
        init()
        DeviceInfoUtils.fetchDeviceInfoBean()
    }

    override fun initData() {
    }

    override fun initListener() {
    }

    private fun init() {
        mVersionNameTv?.text = "版本：".plus(CommUtils.getAppVersionName())
    }

    override fun isRegisterEventBus(): Boolean =true
    override fun receiveEvent(event: Event<Any>) {
        super.receiveEvent(event)
        when (event.code) {
            EventCode.GO_TO_BANNER_SCREEN -> go2FullBanner()
            else -> {}
        }
    }

    /*跳转全屏广告界面*/
    private fun go2FullBanner() {
        ARouter.getInstance()
            .build(ARouterUtils.BannerActivity)
            .navigation(this)
        //finish()
    }
}